package com.fd.fdsso.utils;

import java.util.ResourceBundle;

import com.fd.fdsso.pojo.SSOUserLogin;
import com.fd.util.MyUtils;
import com.lizeng.utils.MyDigestUtils;

/***
 * 单点登录工具箱
 * 
 * @author 符冬
 * 
 */
public final class SSoUtils {
	public static String SSO_DOMAIN = null;
	public static ResourceBundle SSO_RB = ResourceBundle.getBundle("fdsso");
	public final static String CK_LOGINID = "ckLoginId";
	public final static String CK_LOGINNAME = "ckLoginName";
	public final static String CK_SIGNCODE = "ckSignCode";
	public final static String CK_MAIL = "ckMail";

	public static String getLoginCode(SSOUserLogin user) {
		if (user != null && MyUtils.isNotEmpty(user.getUserName())
				&& MyUtils.isNotEmpty(user.getEmail())
				&& MyUtils.isGtZero(user.getLoginId())) {
			StringBuilder bd = new StringBuilder(user.getUserName());
			bd.append(user.getLoginId());
			bd.append(user.getEmail());
			return MyDigestUtils.shaDigest(bd.toString(),
					SSO_RB.getString("SIGN_KEY"));
		}
		return "";
	}
}
